package com.bwie.controller;
import com.bwie.pojo.User;
import com.bwie.service.Impl.UserServiceImpl;
import com.bwie.service.UserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginVo;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.PhoneLoginVo;
import com.bwie.vo.SendVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

/**
* 用户表(tb_user)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/user/user")
public class UserController {
/**
* 服务对象
*/
    @Autowired
    private UserService userService;

    /**
     * 登录
     * @param loginVo
     * @return
     */
    @PostMapping("/login")
    public R login(
            @RequestBody LoginVo loginVo
            ){
        return userService.login(loginVo);
    }

    /**
     * 菜单
     * @param userId
     * @return
     */
    @PostMapping("/treeList/{userId}")
    public R treeList(
        @PathVariable("userId") Integer userId
    ){
        return userService.treeList(userId);
    }

    /**
     * 用户列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/userList")
    public R userList(
            @RequestBody PageInfoVo pageInfoVo
            ){
        return userService.userList(pageInfoVo);
    }

    /**
     * 图片验证码
     * @return
     */
    @GetMapping("/getImageCode")
    public R getImageCode(){
        return userService.getImageCode();
    }

    /**
     * 手机号验证码
     * @param sendVo
     * @return
     */
    @PostMapping("/sendPhoneCode")
    public R sendPhoneCode(
            @RequestBody SendVo sendVo
            ){
        return userService.sendPhoneCode(sendVo);
    }

    /**
     * 手机号登录
     * @param phoneLoginVo
     * @return
     */
    @PostMapping("/phoneLogin")
    public R phoneLogin(
            @RequestBody PhoneLoginVo phoneLoginVo
            ){
        return userService.PhoneLogin(phoneLoginVo);
    }
}
